package ecoll.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

import ecoll.client.database.DatabaseService;
import ecoll.client.database.DatabaseServiceAsync;
import ecoll.client.login.LoginInfo;
import ecoll.client.login.LoginService;
import ecoll.client.login.LoginServiceAsync;
import ecoll.client.quiz.QuizService;
import ecoll.client.quiz.QuizServiceAsync;

public class Client {

	public static final DatabaseServiceAsync DATABASE_SERVICE = GWT
			.create(DatabaseService.class);
	public static LoginServiceAsync LOGIN_SERVICE = GWT
			.create(LoginService.class);
	public static QuizServiceAsync QUIZ_SERVICE = GWT.create(QuizService.class);

	public static LoginInfo LOGIN_INFO = null;
	public static final DockPanel mainPanel = new DockPanel();

	private static Widget lastUpdate = null;

	public static void resetDashboard() {
		updateDashboard(new VerticalPanel());
	}

	public static void updateDashboard(Widget dashboard) {
		if (lastUpdate != null)
			mainPanel.remove(lastUpdate);
		lastUpdate = dashboard;
		dashboard.setStyleName("mainDashboard");
		mainPanel.add(dashboard, DockPanel.EAST);
		mainPanel.setCellWidth(dashboard, "100%");
		dashboard.setWidth("100%"); // 99% ??
	}
	
	public static void fillArea(VerticalPanel panel) {
		VerticalPanel space = new VerticalPanel();
		panel.add(space);
		panel.setCellHeight(space, "100%");
	}

	public static void fillArea(HorizontalPanel panel) {
		HorizontalPanel space = new HorizontalPanel();
		panel.add(space);
		panel.setCellWidth(space, "100%");
	}
}
